home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Finger Server Source / f_main.cp next >
Text File  |  1993-08-12  |  1KB  |  68 lines

  1. /*
  2.  * mac finger sever
  3.  * by Aaron Wohl n3liw+@cmu.edu
  4.  * 412-268-5032 / 412-731-3691
  5.  */
  6.  
  7. #include <stdlib.h>
  8. #include "sip_glue.h"
  9. #include "sip_interface.h"
  10. #include "limits.h"
  11.  
  12. #define xDEBUG
  13.  
  14. /*
  15.  * set to false to exit
  16.  */
  17. int sip_keep_running=TRUE;
  18.  
  19. #define SLEEP_TIME            (ULONG_MAX)
  20.  
  21. #ifdef DEBUG
  22. #define EXTRA_STACK            60000
  23. #include <stdio.h>
  24. #else
  25. #define EXTRA_STACK            12000
  26. #endif
  27.  
  28. /*
  29.  * run a background process to handle a finger server
  30.  */
  31. static int run_finger_server(void)
  32. {
  33.     EventRecord theEvent;
  34.     if(tcp_allocate_memory())
  35.         return TRUE;
  36.     //keep retrying MacTCP
  37.     while(tcp_open_driver())
  38.         WaitNextEvent(everyEvent,&theEvent,10*60,0);
  39.     if(tcp_init_streams())
  40.         return TRUE;
  41.     while(sip_keep_running) {
  42.         if(tcp_ok_to_sleep_now())
  43.             WaitNextEvent(everyEvent,&theEvent,SLEEP_TIME,0);
  44.         tcp_just_awoke();
  45.         tcp_service_event();
  46.     }
  47.     tcp_release_streams();
  48.     return FALSE;
  49. }
  50.  
  51. /*
  52.  * main program for finger server
  53.  */
  54. int main()
  55. {
  56.     SetApplLimit(GetApplLimit()-EXTRA_STACK);
  57.     MaxApplZone();
  58. #ifdef DEBUG
  59.     printf("yo!\n");
  60.     Debugger();
  61. #else
  62.     InitGraf(NewPtr(206) + 202);
  63. #endif
  64.     if(run_finger_server())
  65.         SysBeep(20);
  66.     ExitToShell();
  67. }
  68.